package memento;

/**
 * 用于捕获一个对象的内部状态，以便在将来的某个时候恢复此状态。
 */
public class Test {
    public static void main(String[] args) {
        TextEditor textEditor = new TextEditor();
        textEditor.add("hello");
        textEditor.add(' ');
        textEditor.add("world");

        String state = textEditor.getState();
        System.out.println(state);

        System.out.println("----------------------------------------");

        TextEditor textEditor2 = new TextEditor();
        textEditor2.setState(state);
        System.out.println(textEditor2.getState());

    }
}
